//
//  CardCell.m
//  Guazi
//
//  Created by koolearn on 11-6-1.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "CardCell.h"
#import "CardBriefView.h"

#define kLeft 5
#define kTop 5

@implementation CardCell

@synthesize card;


- (id) initWithCard:(Card*)aCard reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:UITableViewStylePlain reuseIdentifier:reuseIdentifier];
    if (self) {
        self.card = aCard;
        cardView = [[CardBriefView alloc] initWithFrame:CGRectZero];
        cardView.card = aCard;
        cardView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:cardView];
    }
    return self;
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.card = nil;
        cardView = [[CardBriefView alloc] initWithFrame:CGRectZero];
        cardView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:cardView];
    }
    return self;
}


- (void) setCard:(Card *)aCard
{
    [card release];
    card = [aCard retain];
    cardView.card = aCard;
	cardView.backgroundColor = [UIColor whiteColor];
	[cardView setNeedsDisplay];
}

- (void) layoutSubviews
{
    cardView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
    [super layoutSubviews];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    [self setNeedsDisplay];

    // Configure the view for the selected state
}

- (void)dealloc
{
    [card release];
    [cardView release];
    [super dealloc];
}

@end
